//
//	_MiscMergeSetCommand.m -- "set" merge command implementation
//		Written by Don Yacktman Copyright (c) 1995 by Don Yacktman.
//				Version 1.0.  All rights reserved.
//		This notice may not be removed from this source code.
//
//	This object is included in the MiscKit by permission from the author
//	and its use is governed by the MiscKit license, found in the file
//	"LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
//	for a list of all applicable permissions and restrictions.
//	


#import <misckit/miscmerge.h>
#import "_MiscMergeSetCommand.h"

@implementation _MiscMergeSetCommand

static MiscString *myKey = nil;

- parseFromString:(MiscString *)aString
{
	MISC_Merge_Cond_Op operator;
	if (!myKey) {
		myKey = [MiscString new];
		[myKey setStringValue:"set"];
	}
	[self eatKeyWord:myKey from:aString isOptional:NO];
	value1 = [self getArgumentStringFrom:aString toEnd:NO];
	operator = [self getConditionalFrom:aString];
	if (operator != MISC_MCO_EQUAL) {
		id tempString = [MiscString
				newWithString:"Set requires operator to be an =."];
		[self error_conditional:tempString];
		[tempString free];
		value2 = [MiscString new];
	}
	value2 = [self getArgumentStringFrom:aString toEnd:YES];
	[value1 trimWhiteSpaces];
	return self;
}


- executeForMerge:(MiscMergeEngine *)aMerger
{
	[[aMerger class] setGlobalSymbol:value1 toValue:value2];
	return self;
}

@end
